package com.huike.report.service.impl;

import com.huike.business.mapper.TbBusinessMapper;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.common.core.domain.AjaxResult;
import com.huike.contract.mapper.TbContractMapper;
import com.huike.report.domain.vo.IndexVo;
import com.huike.report.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class indexxServiceImpl implements IndexService {
    @Autowired
    private TbClueMapper tbClueMapper;
    @Autowired
    private TbBusinessMapper tbBusinessMapper;
    @Autowired
    private TbContractMapper tbContractMapper;

    @Override
    public IndexVo souYe(String beginCreateTime, String endCreateTime) {
        IndexVo indexVo = new IndexVo();

        Integer cluesNum = tbClueMapper.getCluesNumAll(beginCreateTime, endCreateTime);
        Integer todayCluesNum = tbClueMapper.getOneDayTime();
        Integer businessNum = tbBusinessMapper.getBusinessNum(beginCreateTime, endCreateTime);
        Integer todayBusinessNum = tbBusinessMapper.getOneDayNum();
        Integer contractNum = tbContractMapper.getcontract(beginCreateTime, endCreateTime);
        Integer todayContractNum = tbContractMapper.getOneDayNum(beginCreateTime, endCreateTime);
        Double salesAmount = tbContractMapper.getMoney(beginCreateTime, endCreateTime);
        Double todaySalesAmount = tbContractMapper.getDayTimeMoney();
        Integer tofollowedCluesNum = tbClueMapper.gettofollowedCluesNum(beginCreateTime, endCreateTime);
        Integer tofollowedBusinessNum = tbBusinessMapper.gettofollowedBusinessNum(beginCreateTime, endCreateTime);
        Integer toallocatedCluesNum = tbClueMapper.gettoallocatedCluesNum(beginCreateTime, endCreateTime);
        Integer toallocatedBusinessNum = tbBusinessMapper.gettoallocatedBusinessNum(beginCreateTime, endCreateTime);
        indexVo.setCluesNum(cluesNum);
        indexVo.setBusinessNum(businessNum);
        indexVo.setContractNum(contractNum);
        if (todaySalesAmount != null) {
            indexVo.setTodaySalesAmount(todaySalesAmount);
        }
        indexVo.setTodayBusinessNum(todayBusinessNum);
        indexVo.setTodayCluesNum(todayCluesNum);
        indexVo.setTodayContractNum(todayContractNum);
        if (salesAmount != null) {
            indexVo.setSalesAmount(salesAmount);
        }
        indexVo.setTofollowedCluesNum(tofollowedCluesNum);
        indexVo.setTofollowedBusinessNum(tofollowedBusinessNum);
        indexVo.setToallocatedCluesNum(toallocatedCluesNum);
        indexVo.setToallocatedBusinessNum(toallocatedBusinessNum);
        return indexVo;
    }
}
